<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">
  <caption>个人信息</caption>
  <tr><td>照片:</td><td id="head_td"></td></tr>
  <tr><td>姓名:</td><td id="name_td"></td></tr>
  <tr><td>年龄:</td><td id="age_td"></td></tr>
  <tr><td>好友:</td><td id="friend_td"></td></tr>
</table>
<input type="button" value="请求数据" onclick="f()">
<script>
  function f() {
    //假设下面的数据是从服务器请求到的
    let person = {name:"苍老师",url:"a.jpg",age:30,
      friends:["貂蝉","西施","武则天"]};
    //把对象中的数据显示到页面中,好用通过无序列表展示
    let nameTd = document.querySelector("#name_td");
    let ageTd = document.querySelector("#age_td");
    let headTd = document.querySelector("#head_td");
    let friendTd = document.querySelector("#friend_td");
    nameTd.innerText = person.name;
    ageTd.innerText = person.age;
    //创建图片标签 添加到headTd里面
    let img = document.createElement("img");
    img.src = person.url;
    headTd.append(img);
    //创建ul和li
    let ul = document.createElement("ul");
    //遍历好友数组
    for (let friend of person.friends) {
      //创建li 并把li添加到ul里面
      let li = document.createElement("li");
      li.innerText = friend;
      ul.append(li);
    }
    friendTd.append(ul);//把ul装进td



  }
</script>
</body>
</html>